// var swiper = new Swiper('.swiper-container', {
//   pagination: '.swiper-pagination',
//   paginationClickable: true,
//   mousewheelControl: true,
//   autoplayDisableOnInteraction: false,
//   loop: true,
//   autoplay: 1000,
//   speed: 800,
//   observer: true,
//   observeParents: true
// })

const app = new Vue({
  el: '#app',
  data: {
    title: '',
    search: '',
    banner: [],
    info: '',
    navBar: [],
    ad: [],
    txt: '',
    goods: []
  },
  created() {
    // 获取请求数据
    this.getData()
    setTimeout(() => {
      var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        mousewheelControl: true,
        autoplayDisableOnInteraction: false,
        loop: true,
        autoplay: 1000,
        speed: 800
      })
    }, 100)
  },
  methods: {
    // 获取请求数据
    async getData() {
      const { data } = await axios.get('/page/detail')
      // console.log(data)
      // 解构赋值
      const {
        data: { pageData: res }
      } = data
      // console.log(res)
      // 标题
      this.title = res.page.params.title
      // 搜索框
      this.search = res.items[0].params.placeholder
      // 轮播图
      this.banner = res.items[1].data
      // 店铺公告
      this.info = res.items[2].params.text
      // 导航组
      this.navBar = res.items[3].data
      // 广告
      this.ad = res.items[4].data
      // 富文本
      this.txt = res.items[5].params.content
      // 商品组
      this.goods = res.items[6].data
    },

    // 点击跳转
    log(id) {
      console.log(id)
      localStorage.setItem('goodId', JSON.stringify(id))
      // location.href = './details.html'
    }
  }
})
